<?php
/**
 * Model de Pagos
 *
 *
 * @filesource          
 * @copyright		
 * @link		http://www.pragmatia.com Pragmatia
 * @package		datagro
 * @subpackage	app.models
 * @version     1.1
 * @license		http://www.opensource.org/licenses/mit-license.php The MIT License
 * @author      Marcelo Entraigas <mentraigas@pragmatia.com.ar>
 */


/**
 * Clase Pagos
 *
 * @package	    datagro
 * @subpackage	app.models
 */
class Pago extends AppModel {
    var $name = 'pago';
    
    var $validate = array(
        'CDcomercio' => array(
            'required' => true,
            'rule' => 'CDcomercio'
        ),
        'mediodepago' => array(
            'required' => true,
            'rule' => 'not_empty'
        ),
        'codigo_barras' => array(
            'required' => true,
            'rule' => 'numeric',
        ),
        'codigo_pmc' => array(
            'required' => true,
            'rule' => 'numeric',
        ),
        'aplicacion' => array(
            'required' => true,
            'rule' => 'not_empty'
        ),
        'generador' => array(
            'required' => true,
            'rule' => 'not_empty'
        ),
        'concepto' => array(
            'required' => true,
            'rule' => 'not_empty'
        ),
        'monto_bruto' => array(
            'required' => true,
            'rule' => array('decimal', 2)
        ),
        'monto_neto' => array(
            'required' => true,
            'rule' => array('decimal', 2)
        ),
        'fecha_generado' => array(
            'numeric'=>array(
                'required' => true,
                'rule' => 'numeric'
            ),
            'minLength'=>array(
                'rule' => array('minLength', 8)
            )
            
        ),
        'fecha_vencimiento' => array(
            'numeric'=>array(
                'required' => true,
                'rule' => 'numeric'
            ),
            'minLength'=>array(
                'rule' => array('minLength', 8)
            )
        ),
        'fecha_pago' => array(
            'numeric'=>array(
                'required' => true,
                'rule' => 'numeric'
            ),
            'minLength'=>array(
                'rule' => array('minLength', 8)
            )  
        ),
        'fecha_acreditacion' => array(
            'numeric'=>array(
                'required' => true,
                'rule' => 'numeric'
            ),
            'minLength'=>array(
                'rule' => array('minLength', 8)
            )
        ),
        'fecha_disponible' => array(
            'numeric'=>array(
                'required' => true,
                'rule' => 'numeric'
            ),
            'minLength'=>array(
                'rule' => array('minLength', 8)
            )
        ),
        'F2z8SKd5T95aw5HSWmeGyO94jUdv9K87c55dMpV15busf92v9OGakF7J3Z2'=>array(
            'required' => true,
            'rule' => 'codigo_secreto'
        )
    );
    
    /**
     * Valido que no este vacio
     */
    function not_empty($field){
        return !empty($field);
    }
    
    /**
     * valido el codigo de comercio
     */
    function CDcomercio($field){
        if( $field==='GB389962' ){
            return true;
        }
        return false;
    }
    
    /**
     * Valido el parametro este correctamente seteado
     */
    function codigo_secreto($field){
        if( $field==='F2z8SKd5T95aw5HSWmeGyO94jUdv9K87c55dMpV15busf92v9OGakF7J3Z2' ){
            return true;
        }
        return false;
    }
    
} 
?>